#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int > vec;
typedef pair < int , int > pii;

ll read() {
    ll x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1e5 + 10,B = 316;

int a[N],n,Q,bel[N];

int gcd(int x,int y) { return !y ? x : gcd(y,x % y); }

struct BLOCK {
    int l,r,val[B + 10],bxor[B + 10],bgcd[B + 10],len;
    map < ll , int > axor;
    void rebuild() {
	map < ll , int > () .swap(axor);
	for(int i = 1;i <= len;i++) bgcd[i] = gcd(bgcd[i - 1],val[i]);
	for(int i = 1;i <= len;i++) bxor[i] = bxor[i - 1] ^ val[i];
	for(int i = len;i >= 1;i--) axor[bxor[i]] = i + l - 1;
    }
    void build() {
	for(int i = l;i <= r;i++) val[i - l + 1] = a[i];
	len = r - l + 1; rebuild();
    }
    int find(int lxor,int lgcd,ll x) {
	for(int i = 1;i <= len;i++) if(((ll) (lxor ^ bxor[i]) * gcd(bgcd[i],lgcd)) == x) return i + l - 1;
	return -1;
    }
    void modify(int x,int y) { val[x - l + 1] = y; rebuild(); }
    int egcd() { return bgcd[len]; }
    int exor() { return bxor[len]; }
    int get(ll ned) { return axor.find(ned) == axor.end() ? 0 : axor[ned]; }
} t[N / B + 10];

int query(ll x) {
    int cxor = 0,cgcd = 0;
    for(int i = 1;i <= bel[n];i++) {
	if(gcd(cgcd,t[i].egcd()) == cgcd) {
	    if(x % cgcd == 0) {
		ll ned = x / cgcd; int p = t[i].get(ned ^ cxor); 
		if(p) return p;
	    }
	} else {
	    int res = t[i].find(cxor,cgcd,x);
	    if(res != -1) return res;
	}
	cxor = cxor ^ t[i].exor();
	cgcd = gcd(cgcd,t[i].egcd());
    } return -1;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    n = in; for(int i = 1;i <= n;i++) a[i] = in; Q = in;
    for(int i = 1;i <= n;i++) bel[i] = (i - 1) / B + 1,t[bel[i]].r = i;
    for(int i = 1;i <= bel[n];i++) t[i].l = t[i - 1].r + 1;
    for(int i = 1;i <= bel[n];i++) t[i].build();
    while(Q--) {
	char op = getchar(); while(!isalpha(op)) op = getchar();
	if(op == 'M') {
	    int id = in + 1,x = in; t[bel[id]].modify(id,x);
	} else {
	    ll x = in; int ans = query(x); if(ans == -1) puts("no"); else printf("%d\n",ans - 1);
	}
    } return 0;
}
